package com.cisco.vsx.email.dao;

import java.util.List;
import java.util.Set;

import com.cisco.vsx.email.Template;
import com.cisco.vsx.email.exceptions.EventNotFoundException;
import com.cisco.vsx.email.exceptions.TemplateNotFoundException;


/**
 * @author naresred
 *
 */
public interface IEmailTemplateDAO {
	
	/**
	 * Creates a new email template with specified information. If the event information is not found, this method throws
	 * @EventNotFoundException
	 * 
	 * @param templateName
	 * @param localeName
	 * @param content
	 * @param eventName
	 * @param isDefault
	 * @param isActive
	 * @throws EventNotFoundException
	 */
	public void createTemplate(String templateName, String description, String localeName, String content, String eventName, boolean isDefault, boolean isActive) throws EventNotFoundException;
	
	/**
	 * Creates a new email template with specified information. If the event information is not found, this method throws
	 * @EventNotFoundException
	 * 
	 * @param template
	 * @throws EventNotFoundException
	 */
	public void createTemplate(Template template) throws EventNotFoundException;
	
	/**
	 * Updates an email template with the information provided. As there can be multiple templates with the same name 
	 * (template name is NOT unique) template id must be provided. If the template id is not found in the system this
	 * method throws @TemplateNotFoundException  
	 * 
	 * @param templateId
	 * @param templateName
	 * @param description
	 * @param localeName
	 * @param content
	 * @throws TemplateNotFoundException
	 * @throws EventNotFoundException
	 */
	public void updateTemplate(int templateId, String templateName, String description, String localeName, String content, String eventName) throws TemplateNotFoundException, EventNotFoundException;
	
	/**
	 * Updates an email template with the information provided. As there can be multiple templates with the same name 
	 * (template name is NOT unique) template id must be provided. If the template id is not found in the system this
	 * method throws @TemplateNotFoundException
	 * 
	 * @param template
	 * @throws TemplateNotFoundException
	 * @throws EventNotFoundException 
	 */
	public void updateTemplate(Template template) throws TemplateNotFoundException, EventNotFoundException;
	/**
	 * Deactivates an email template. Deactivated templates can't be used for sending emails without being activated.
	 * 
	 * @param templateId
	 * @param localeName
	 * @throws TemplateNotFoundException
	 */
	public void deactivateTemplate(int templateId) throws TemplateNotFoundException;
	
	/**
	 * Activates a template
	 * 
	 * @param templateId
	 * @throws TemplateNotFoundException
	 */
	public void activateTemplate(int templateId) throws TemplateNotFoundException;
	
	/**
	 * Deactivates all templates associated to an event
	 * 
	 * @param eventName
	 * @throws EventNotFoundException
	 * @throws TemplateNotFoundException 
	 */
	public void deactivateTemplates(String eventName) throws EventNotFoundException, TemplateNotFoundException;
	
	/**
	 * Activates all templates associated to an event
	 * 
	 * @param eventName
	 * @throws EventNotFoundException
	 * @throws TemplateNotFoundException 
	 */
	public void activateTemplates(String eventName) throws EventNotFoundException, TemplateNotFoundException;
		
	/**
	 * Method to get all supported locales for an event
	 * 
	 * @param eventName
	 * @return Set<String>
	 * @throws TemplateNotFoundException
	 */
	public Set<String> getSupportedLocales(String eventName) throws EventNotFoundException;
	
	/**
	 * Retrieves a template with specified Id. If not found, throws @TemplateNotFoundException
	 * 
	 * @param templateId
	 * @return Template
	 * @throws TemplateNotFoundException
	 */
	public Template getTemplate(int templateId) throws TemplateNotFoundException;
		
	/**
	 * Retrieves templates matches the criteria. Returns empty list if no results found.
	 * 
	 * @param eventName
	 * @param localeName
	 * @return List<Template>
	 */
	public List<Template> getTemplates(Template template);
	
	/**
	 * Adds an image or attachment to template
	 * 
	 * @param templateId
	 * @param imageName
	 * @param content
	 * @param mimeType
	 * @param isAttachment
	 * @throws TemplateNotFoundException
	 */
	public void addTemplateContent(int templateId, String imageName, byte[] content, String mimeType, boolean isAttachment) throws TemplateNotFoundException;
	
	/**
	 * Marks an email template as non default.
	 * 
	 * @param templateId
	 * @throws TemplateNotFoundException
	 */
	public void markTemplateAsNonDefault(int templateId) throws TemplateNotFoundException;
	
	/**
	 * Marks an email template as default.
	 * 
	 * @param templateId
	 * @throws TemplateNotFoundException
	 */
	public void markTemplateAsDefault(int templateId) throws TemplateNotFoundException;
	
}
